import 'package:flutter_pink_app/net/base/response.dart';
import 'package:flutter_pink_app/net/request/profile_request.dart';
import 'package:flutter_pink_app/serialized/profile.dart';
import '../net/index.dart';
import '../net/adater/dio_adapter.dart';
import '../util.dart';

const _successStatus = 'SUCCESS.'; // 请求成功标识

// 个人中心页请求列表方法
Future<ProfileSerializedGen> getProfileInfo() async {
  // 安全类型检测
  final network = NetworkCall.getInstance(adapter: DioAdapter());
  BaseResponse<Map<String, dynamic>> response;
  final req = ProfileRequest();
  try {
    response = await network.send(req);
  } catch (e) {
    logCurrStackTrace(); // 打印当前堆栈信息
    print('请求个人中心页接口时发生错误。$e');
    return null;
  }
  assert(response.message == _successStatus, '个人中心页接口返回的数据状态码不正确');
  // 如果请求状态成功则执行序列化
  return ProfileSerializedGen.fromJson(response.data);
}
